<?php
class My_Helper_View_Caption extends Zend_View_Helper_Abstract
{
	public function caption($field, $title , $enable = true)
	{
		if($enable)
		{
			$cmd = $_POST["cmd"];
			if($cmd == "sort")
			{		
				$order = split(";",$_POST['params']);
				$orderBy = $order[0];
				$orderDirection = $order[1];
			}
	    	if($orderBy == $field)
	    	{
	    		$baseURL = $this->view->baseURL;
	    		$img = "<img src=\"".$baseURL."/images/t_sort_$orderDirection.png\"/>";
	    		$orderDirection = ($orderDirection == "asc")?"desc":"asc";
	    	}
	    	if(!isset($orderDirection))
	    	{
	    		$orderDirection = "asc";
	    	}
	    	$html = "<a href=\"javascript:sort('".$field."','".$orderDirection."')\">".$title."$img</a>";
		}
		else
		{
			$html = $title;
		}
    	
        return $html;
	}
	
}